<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>storage</title>
		<script>
			function saveName(){
				let d=document.getElementById("yourname");
				//window.sessionStorage.setItem("mingzi",d.value);
				window.localStorage.setItem("mingzi",d.value);
				//JSON.stringify();//对象到String
				//JSON.parse()//string到对象
				//window.localStorage.clear()
				alert("ok");
			}
		</script>
	</head>
	<body>
		<div>
			<input type="text" id="yourname" placeholder="请输入你的名字"/>
			<input type="button" value="存入" onclick="saveName()"/>
			<a href="get.html">获得名字</a>
		</div>
	</body>
</html>